/**
作用是给每个生成的模板加一个版权声明的注释
 */
const loaderUtils = require('loader-utils');
const validateOptions = require('schema-utils');
const fs = require('fs');
const path = require('path');
function loader(inputSource,inputSourceMap){
  let callback= this.async();
  debugger;
  this.cacheable();//启动缓存
  let options = loaderUtils.getOptions(this);
  let schema = {
      type:'object',
      properties:{
          filename:{type:'string'},
          text:{type:'string'}
      }
  }  
  validateOptions(schema,options);
  let {filename} = options;
  fs.readFile(path.join(__dirname,filename),'utf8',(err,text)=>{
     callback(null,text+inputSource,inputSourceMap);
  });
}
module.exports = loader;